<!--{template common/header_simple_start}-->
<link href="static/css/common.css?{VERHASH}" rel="stylesheet" media="all">
<link href="dzz/connect/images/connect.css?{VERHASH}" rel="stylesheet" media="all">
<script type="text/javascript" src="static/js/jquery.leftDrager.js?{VERHASH}"></script>
<style>
html,body{
	overflow:hidden;
	background:#FBFBFB;
}
.bs-left-container{
	width:120px;
}
.bs-main-container{
	margin-left:120px;
	overflow:auto;
}

</style>
<!--{template common/header_simple_end}-->
<div class="bs-container clearfix">
  <div class="bs-left-container  clearfix">
    <!--{template left}--> 
  </div>
  <div class="left-drager">
     <div class="left-drager-op"><div class="left-drager-sub"></div></div>
  </div>
  <div class="bs-main-container  clearfix">
  <div class="main-header clearfix">
    <ul class="nav nav-pills nav-pills-bottomguide">
      <li ><a href="{BASESCRIPT}?mod=cloud&op=edit&bz=dzz"> 设置</a></li>
      <li ><a href="{BASESCRIPT}?mod=cloud&op=space">空间管理</a></li>
      <li class="active"><a href="{BASESCRIPT}?mod=cloud&op=oauth&bz=JSS">添加京东存储</a></li>
    </ul>
  </div>
  <div class="main-content clearfix"  style="border-top:1px solid #FFF">
    <div style="padding:15px;">
      <h4 style="margin-bottom:20px">设置accessKey 和 secretKey</h4>
      <form  name="aliform" class="form-horizontal form-horizontal-left" action="{BASESCRIPT}?mod=cloud&op=oauth" method="post" onsubmit="return validate(this)">
        <input type="hidden" name="jsssubmit" value="true" />
        <input type="hidden" name="bz" value="JSS" />
        <input type="hidden" name="formhash" value="{FORMHASH}" />
        <div class="form-group">
          <label class="control-label" for="email">accessKey</label>
          <div class="controls">
            <input type="text" id="access_id" class="form-control"  name="access_id" autocomplete="off" value="$ali[access_id]" onblur="if(this.value==''){jQuery(this).block().parent().addClass('warning');}else{jQuery(this).parent().parent().removeClass('warning');getBucket();}">
             </div>
             <span  class="help-block">京东云存储accessKey</span>
        </div>
        <div class="form-group">
          <label class="control-label" for="email">secretKey</label>
          <div class="controls">
            <input type="password" class="form-control" id="access_key" name="access_key" autocomplete="off" value="$ali[access_id]" onblur="if(this.value==''){jQuery(this).parent().parent().addClass('warning');}else{jQuery(this).parent().parent().removeClass('warning');getBucket();}">
            </div>
            <span  class="help-block">京东云存储secretKey</span> 
        </div>
        <div class="form-group">
          <label class="control-label" ><a href="javascript:;" onclick="getBucket()">点此获取bucket列表</a></label>
          <div class="controls">
            <select id="bucket" name="bucket" class="form-control" onchange="if(this.value==''){jQuery(this).parent().parent().addClass('warning')}else{jQuery(this).parent().parent().removeClass('warning')}">
              <option value="" >请选择bucket</option>
            </select>
             </div>
             <span  class="help-block">选择要使用的bucket，点击左侧的连接可以自动获取bucket列表，如果没有bucket请先创建</span>
        </div>
        <div class="form-group">
        <label class="control-label" ></label>
        <div class="controls">
          <input type="submit" class="btn btn-primary" value="添加" >
        </div>
      </form>
    </div>
  </div>
</div>
<script type="text/javascript">
 jQuery('.left-drager').leftDrager_layout();
function getBucket(){
	var id=jQuery("#access_id").val();
	var key=jQuery("#access_key").val();
	if(id=='' || key==''){
		return ;
	}
	jQuery.getJSON('{BASESCRIPT}?mod=cloud&op=oauth&do=getBucket',{id:id,key:key,bz:'JSS'},function(json){
		if(json.length>0){
			var html='<option value="" >请选择bucket</option>';
			for(var i in json){
				html+='<option value="'+json[i]+'" >'+json[i]+'</option>';
			}
			jQuery('#bucket').html(html);
			jQuery('#bucket').parent().parent().find('.control-label').html('<span class="text-success">bucket获取成功,请选择</span>');
		}
	});
	
}
function validate(form){
	if(jQuery("#access_id").val()==''){
		jQuery("#access_id").parent().parent().addClass('warning');
		return false;
	}else if(jQuery("#access_key").val()==''){
		jQuery("#access_key").parent().parent().addClass('warning');
		return false;
	}else if(jQuery("#bucket").val()==''){
		jQuery("#bucket").parent().parent().addClass('warning');
		return false;
	}
	return true;
}
jQuery(document).ready(function(e) {
  
});



 </script> 
<!--{template common/footer_simple}--> 
